package com.ruoyi.flow.flow.workflow;

import com.ruoyi.flow.auth.security.FlowUser;
import com.ruoyi.flow.flow.workflow.FlowService;
import org.activiti.engine.identity.User;

import java.util.Objects;

/**
 * @author wtian
 * @version 1.0
 * @since 2018/9/4 16:56
 */
public class FlowProfile {
    /**
     * 用户ID
     */
    private String userId;
    /**
     * 用户邮箱
     */
    private String email;
    /**
     * 用户姓名。firstName+lastName
     */
    private String userName;

    public FlowProfile(User user) {
        if (user != null) {
            this.userId = user.getId();
            this.userName = Objects.toString(user.getFirstName(), "") + Objects.toString(user.getLastName(), "");
            this.email = user.getEmail();
        }
    }

    public FlowProfile(String userId) {
        this(FlowService.identityService().getUserByUserId(userId));
    }

    public FlowProfile(FlowUser flowUser) {
        this(flowUser == null ? null : flowUser.getUser());
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
}
